package org.wtj.service.sys;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.wtj.entity.ResponsePageEntity;
import org.wtj.entity.sys.SysDictDetailConditionEntity;
import org.wtj.entity.sys.SysDictDetailEntity;
import org.wtj.mapper.BaseMapper;
import org.wtj.mapper.sys.SysDictDetailMapper;
import org.wtj.service.BaseService;

import java.util.List;

/**
 * 部门 服务层
 *
 * @author wang 该项目是知识星球：java突击队 的内部项目
 * @date 2025-03-06 21:50:54
 */
@Service
public class SysDictDetailService extends BaseService<SysDictDetailEntity, SysDictDetailConditionEntity> {

	@Autowired
	private SysDictDetailMapper sysDictDetailMapper;

	/**
     * 查询部门信息
     *
     * @param id 部门ID
     * @return 部门信息
     */
	public SysDictDetailEntity findById(Long id) {
	    return sysDictDetailMapper.findById(id);
	}

	/**
     * 根据条件分页查询部门列表
     *
     * @param sysDictDetailConditionEntity 部门信息
     * @return 部门集合
     */
	public ResponsePageEntity<SysDictDetailEntity> searchByPage(SysDictDetailConditionEntity sysDictDetailConditionEntity) {
		int count = sysDictDetailMapper.searchCount(sysDictDetailConditionEntity);
		if (count == 0) {
			return ResponsePageEntity.buildEmpty(sysDictDetailConditionEntity);
		}
		List<SysDictDetailEntity> dataList = sysDictDetailMapper.searchByCondition(sysDictDetailConditionEntity);
		return ResponsePageEntity.build(sysDictDetailConditionEntity, count, dataList);
	}

    /**
     * 新增部门
     *
     * @param sysDictDetailEntity 部门信息
     * @return 结果
     */
	public int insert(SysDictDetailEntity sysDictDetailEntity) {
	    return sysDictDetailMapper.insert(sysDictDetailEntity);
	}

	/**
     * 修改部门
     *
     * @param sysDictDetailEntity 部门信息
     * @return 结果
     */
	public int update(SysDictDetailEntity sysDictDetailEntity) {
	    return sysDictDetailMapper.update(sysDictDetailEntity);
	}

	/**
     * 批量删除部门对象
     *
     * @param ids 系统ID集合
     * @return 结果
     */
	public int deleteByIds(List<Long> ids) {
		List<SysDictDetailEntity> entities = sysDictDetailMapper.findByIds(ids);

		SysDictDetailEntity entity = new SysDictDetailEntity();
		return sysDictDetailMapper.deleteByIds(ids, entity);
	}

	@Override
	protected BaseMapper getBaseMapper() {
		return sysDictDetailMapper;
	}

}
